﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Linq;
using CommonModule;
using System.Collections.Generic;
using Microsoft.Practices.Composite.Presentation.Commands;
using Services;

namespace MenuModule
{
    public class MenuViewViewModel
    {
        public List<CommandDefinition> Commands { get; set; }

        public ICommand RootCommand { get; set; }

        public MenuViewViewModel()
        {
           CommandService objService=SingletonUnityService.Instance.GetByType<CommandService>();
           this.RootCommand = new DelegateCommand<object>(OnListClicked);
           this.Commands = objService.GetCommandsByRole(Roles.Admin);
        }

        public void OnListClicked(object parm)
        {
            CommandDefinition cmd = parm as CommandDefinition;
            CommandDefinition result = (from d in this.Commands
                                  where d == cmd
                                  select d).ToList()[0];
            result.MenuCommand.Execute(parm);
          

        }
       
      
    }
}
